package com.wechat.service.storage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.swak.annotation.FluxService;
import com.swak.entity.Page;
import com.swak.entity.Parameters;
import com.swak.persistence.QueryCondition;
import com.swak.service.BaseService;
import com.wechat.dto.ContactHeadimgDTO;
import com.wechat.entity.ContactHeadimg;
import com.wechat.service.ContactHeadimgService;
import com.wechat.service.storage.mapper.ContactHeadimgMapper;

/**
 * 描述
 * 
 * @author Auto Generator
 * @date 2022-10-21T23:59:27.272484900
 */
@FluxService
@Service("wechatContactHeadimgService")
public class ContactHeadimgServiceImpl extends BaseService<ContactHeadimg, String> implements ContactHeadimgService {

	@Autowired
	private ContactHeadimgMapper contactHeadimgMapper;

	/**
	 * 直取
	 */
	@Override
	public ContactHeadimgDTO get(String id) {
		return ContactHeadimgDTO.convert(this.contactHeadimgMapper.get(id));
	}

	/**
	 * 保存
	 */
	@Override
	@Transactional
	public ContactHeadimgDTO save(ContactHeadimgDTO contactHeadimg) {
		this.contactHeadimgMapper.merge(contactHeadimg.transform(), true);
		return this.get(contactHeadimg.getId());
	}

	/**
	 * 删除
	 */
	@Override
	@Transactional
	public Integer delete(ContactHeadimgDTO contactHeadimg) {
		ContactHeadimg entity = contactHeadimg.transform();
		return this.contactHeadimgMapper.delete(entity);
	}

	/**
	 * 分页查询
	 */
	@Override
	public Page<ContactHeadimgDTO> page(ContactHeadimgDTO query, Parameters param) {
		QueryCondition qc = new QueryCondition();
		qc.getCriteria().andEqualTo(ContactHeadimg.DelFlag, Boolean.FALSE);
		qc.setOrderByClause(param.orderBy(ContactHeadimg.DefaultOrderBy));
		return ContactHeadimgDTO.convert(this.contactHeadimgMapper.queryForPage(qc, param));
	}
}
